package org.thirdHero.db.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * rabbitMq生产者类
 * @author zhanghang
 * @date 2018/12/13
 */
@Component
public class RabbitSender {
    private static final Logger logger = LoggerFactory.getLogger(RabbitSender.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;


/*    *//**
     * 发送订单信息
     * @param freshOrder
     *//*
    public void sendPayOverTime(FreshOrder freshOrder) {
        logger.info("【加入队列---订单超时未处理,时间:{},订单id:{}】===============处理订单超时未支付====================",LocalDateTime.now(),freshOrder.getId());
        // 通过广播模式发布延时消息 延时30分钟 持久化消息 消费后销毁 这里无需指定路由，会广播至每个绑定此交换机的队列
        rabbitTemplate.convertAndSend(RabbitConfig.Delay_Exchange_Name, "", freshOrder.getId(), message ->{
            message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT);
            message.getMessageProperties().setDelay(15 * (60*1000));   // 毫秒为单位，指定此消息的延时时长
            return message;
        });
    }*/


}